package com.gitee.wsl.flow.create.datasource.source

import com.gitee.wsl.flow.create.datasource.BaseFlowDataSource
import com.gitee.wsl.flow.create.datasource.FlowDataSource
import com.gitee.wsl.flow.create.datasource.request.ExecutableRequest
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

typealias ExecutableDataSourceType<T> = FlowDataSource<ExecutableRequest<T>, T>

class ExecutableFlowDataSource<T : Any>(
    cacheDataSource: FlowDataSource<ExecutableRequest<T>, T>? = null,
    coroutineContext: CoroutineContext = EmptyCoroutineContext
) : BaseFlowDataSource<ExecutableRequest<T>, T>(cacheDataSource, coroutineContext) {
    override suspend fun internalRead(request: ExecutableRequest<T>): T = request.block()
}
